package com.itbaizhan.openhis.controller;

import com.itbaizhan.openhis.dto.LoginInfoDto;
import com.itbaizhan.openhis.service.LoginInfoService;
import com.itbaizhan.openhis.vo.AjaxResult;
import com.itbaizhan.openhis.vo.DataGridView;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录日志控制器
 */
@RestController
@RequestMapping("system/loginInfo")
@Slf4j
public class LoginInfoController {
	
	@Autowired
	private LoginInfoService loginInfoService;
	/**
	 * 分页查询登录日志
	 */
	@GetMapping("listForPage")
	public AjaxResult listForPage(LoginInfoDto loginInfoDto) {
		log.info("分页查询登录日志，参数：{}", loginInfoDto);
		DataGridView dataGridView = loginInfoService.listForPage(loginInfoDto);
		return AjaxResult.success("查询成功", dataGridView.getData(),  dataGridView.getTotal());
	}
	
	/**
	 * 批量删除登录日志
	 * @param InfoIds
	 * @return
	 */
	@DeleteMapping("deleteLoginInfoByIds/{InfoIds}")
	public AjaxResult deleteLoginInfoByIds(@PathVariable Long[] InfoIds) {
		log.info("删除登录日志,参数：{}", InfoIds);
		
		return AjaxResult.toAjax(loginInfoService.deleteLoginInfoByIds(InfoIds));
	}
	
	/**
	 * 清空登录日志
	 * @return
	 */
	@DeleteMapping("clearLoginInfo")
	public AjaxResult clearLoginInfo() {
		log.info("清空登录日志");
		return AjaxResult.toAjax(loginInfoService.clearLoginInfo());
	}
}
